package com.ctgu.蓝桥杯真题.B组2015;

/**
 * @author: Backdiy
 * @data: 2021/4/15 16:49
 * @desc:
 */
public class 牌型总数7 {
    public static void main(String[] args) {
        暴力求解.main();
        深搜.main();
        动态规划.main();
    }

    static class 暴力求解 {
        public static void main() {
            int ans = 0;
            for (int i = 0; i < 5; i++) {
                for (int j = 0; j < 5; j++) {
                    for (int k = 0; k < 5; k++) {
                        for (int l = 0; l < 5; l++) {
                            for (int m = 0; m < 5; m++) {
                                for (int n = 0; n < 5; n++) {
                                    for (int o = 0; o < 5; o++) {
                                        for (int p = 0; p < 5; p++) {
                                            for (int q = 0; q < 5; q++) {
                                                for (int r = 0; r < 5; r++) {
                                                    for (int s = 0; s < 5; s++) {
                                                        for (int t = 0; t < 5; t++) {
                                                            for (int u = 0; u < 5; u++) {
                                                                if (i + j + k + l + m + n + o + p + q + r + s + t + u == 13)
                                                                    ans++;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            System.out.println(ans);
        }
    }

    static class 深搜 {
        static int ans = 0;

        public static void main() {
            dfs(0, 0);
            System.out.println(ans);
        }

        static void dfs(int n, int m) {
            if (n > 13 || m > 13) {
                return;
            }
            if (m == 13) {
                ans++;
                return;
            }
            for (int i = 0; i < 5; i++) {
                dfs(n + 1, m + i);
            }
        }
    }

    static class 动态规划 {
        //dp[i][j]表示第i种数取了j张牌时的牌型总数
        //dp[i][j]+=dp[i-1][j-k]
        static int[][] dp = new int[14][14];
        static int ans = 0;

        public static void main() {
            dp[1][0] = dp[1][1] = dp[1][2] = dp[1][3] = dp[1][4] = 1;
            for (int i = 2; i <= 13; i++) {
                for (int j = 0; j <= 13; j++) {
                    for (int k = 0; k <= 4; k++) {
                        if (j - k >= 0) {
                            dp[i][j] += dp[i - 1][j - k];
                        }
                    }
                }
            }
            ans=dp[13][13];
            System.out.println(ans);
        }
    }
}
